package com.ruoyi.web.controller.ucenter.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ucenter.service.ISmsCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.mail.MessagingException;

/**
 * @author : 张怀秋
 **/
@Api(tags = "短信服务")
@RestController
@RequestMapping("/api/u-center")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SmsCodeController extends BaseController {
    private final ISmsCodeService smsCodeService;

    @ApiOperation("发送短信验证码接口")
    @GetMapping("/getCode/{phone}")
    public AjaxResult sendValidateCode(@ApiParam(value = "手机号", required = true) @PathVariable String phone) {
        return smsCodeService.sendValidateCode(phone);
    }
    @ApiOperation("发送邮箱验证码接口")
    @GetMapping("/getEmailCode/{mail}")
    public AjaxResult sendEmailValidateCode(@ApiParam(value = "邮箱", required = true) @PathVariable String mail) throws MessagingException {
        return smsCodeService.sendMailCode(mail);
    }
}
